//
//  ViewController.m
//  Btn
//
//  Created by Justsoso on 16/3/17.
//  Copyright © 2016年 Justsoso. All rights reserved.
//

#import "ViewController.h"

#import "MyButton.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)btnPressed:(MyButton *)sender
{
    if (sender.addBtn != nil)
    {
        [sender.addBtn removeFromSuperview];
    }
    else
    {
        UIButton *btn = [[UIButton alloc] init];
        btn.bounds = CGRectMake(0, 0, 200, 200);
        btn.center = CGPointMake(100, -100);
        
        [btn setBackgroundImage:[UIImage imageNamed:@"对话框"] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"小孩"] forState:UIControlStateHighlighted];
        
        [sender addSubview:btn];
        
        sender.addBtn = btn;
    }
    
}

@end
